package OOP.Day04.Work03;

public class Counter {
    //加减乘除
    public int Sum(int num1, int num2, int num3){
        int num = 0;
        switch (num1){
            case 1:
                num = num2 + num3;
                break;
            case 2:
                num = num2 - num3;
                break;
            case 3:
                num = num2 * num3;
                break;
            case 4:
                num = num2 / num3;
                break;
        }
        return num;
    }

    //累加
    public int LeiJia(int num1, int num2){
        int sum = 0;
        for (int i = num1; i <= num2; i++) {
            sum += i;
        }
        return sum;
    }

    //阶乘
    public int JieCheng(int num){
        int product = 1;
        if (num == 0){

        }else {
            for (int i = 1; i <= num; i++) {
                product *= i;
            }
        }

        return product;
    }

    //平方
    public int Square(int num1){
        int num = num1 * num1;
        return num;
    }

    //次方
    public int Power(int num1, int num2){
        int num = 1;
        for (int i = 1; i <= num2; i++){
            num = num * num1;
        }
        return num;
    }

    //素数
    public boolean Prime(int num){
        boolean isPrime = false;
        if (num<=1){
            System.out.println(num+"不是素数");
            isPrime = false;
        }else {
            if (num%2!=0 && (num/num==1)){
                System.out.println(num+"是素数");
                isPrime = true;
            }else {
                System.out.println(num+"不是素数");
            }
        }
        return isPrime;
    }

}
